<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>连锁干洗中心业务管理系统</title>
    <%- include('css') %>
</head>

<body class="layui-layout-body">
    <div class="layui-layout layui-layout-admin">
        <%- include('header') %>
        <%- include('menu') %>

        <div class="layui-body">
            <!-- 内容主体区域 -->
            <div>
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                    <legend>充值</legend>
                </fieldset>

                <form name="form1" class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <!--<div class="layui-inline">-->
                            <label class="layui-form-label">顾客账号</label>
                            <div class="layui-input-block" style="width: 250px;">
                                <input type="text" id="username" name="username" lay-verify="required" placeholder="输入顾客账号" autocomplete="off" class="layui-input">
                            </div>
                        <!--</div>-->
                    </div>
                    <div class="layui-form-item">
                            <label class="layui-form-label">充值金额</label>
                            <div class="layui-input-block" style="width: 250px;">
                                <input type="number" id="money" name="money" lay-verify="required" placeholder="￥" autocomplete="off" class="layui-input">
                            </div>
                    </div>
                    <div class="layui-form-item">
                        <!--<div class="layui-inline">-->
                            <label class="layui-form-label">确认管理员密码</label>
                            <div class="layui-input-block" style="width: 250px;">
                                <input type="password" id="password" name="password" lay-verify="required" placeholder="输入管理员密码" autocomplete="off" class="layui-input">
                            </div>
                        <!--</div>-->
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" v-bind:disabled="isButtonDisabled" lay-submit="" lay-filter="search">提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>


        <%- include('footer') %>
    </div>
    <%- include('script') %>

    <script>
        var table;
        var form;
        var vm = new Vue({
            el: '#app',
            data:function() {
                return {
                    isButtonDisabled: false,
                }
            },
            mounted: function () {
                var self = this;
                layui.use(['element', 'form', 'laytpl'], function () {

                    var laytpl = layui.laytpl,
                        element = layui.element;
                    form = layui.form;

                    //查询按钮
                    form.on('submit(search)', function (data) {
                        self.isButtonDisabled = true;
                        $.ajax({
                            url:'/admin/recharge',
                            type:'POST',
                            data:{data:data.field},
                            success:(res)=>{
                                if (res.code == 200) {
                                    layer.msg('充值请求提交成功!充值成功延迟1-3分钟！',{icon:1})
                                } else {
                                    //icon 1绿√ 2红叉 3问号 4密码锁 5不开心 6开心
                                    layer.msg('充值失败:'+res.error+' -- '+res.code,{icon:2})
                                }
                                self.isButtonDisabled = false;
                            }
                        });
                        return false;
                    });
                })
            },
            methods: {
                iframeclose: function () {
                },
            }
        })
    </script>
</body>

</html>
